{Mjagkova_Jana 04.12 Klass+nasledovanie}
program Rectangle1;

{$APPTYPE CONSOLE}

uses
SysUtils;

type

rectangle=class
  procedure Square;
  procedure update;
  Constructor Create(newa,newb:integer);

  public
    a,b:integer;
  private
    S:integer;

end;

Smartrectangle=class(Rectangle)
  procedure St(newa,newb:integer);
  procedure Square;
end;

procedure Rectangle.Square;
begin
  Writeln('S=',s);
end;

procedure Rectangle.update;
begin
  S:=a*b;
end;

Constructor Rectangle.Create(newa,newb:integer);
begin
  a:=newa;
  b:=newb;
  S:=a*b;
end;

procedure Smartrectangle.St(newa,newb:integer);
begin
  a:=newa;
  b:=newb;
  S:=newa*newb;
end;

procedure SmartRectangle.Square;
begin
  If S=a*b then
    Writeln(s)
  Else
    Writeln('no');
  end;

var
  C:Rectangle;
  V:SmartRectangle;
begin

  writeln('Class Rectangle');
  C:=Rectangle.Create(5,6);
  writeln('a=',C.a,' b=',C.b);
  C.Square;

  C.a:=9;
  C.b:=3;
  writeln('a=',C.a,' b=',C.b);
  C.update;
  C.Square;

  C.a:=7;
  C.b:=8;
  writeln('a=',C.a,' b=',C.b);
  C.Square;
  writeln;

  writeln('Class SmartRectangle');
  V:=SmartRectangle.Create(3,4);
  writeln('a=',V.a,' b=',V.b);
  V.Square;

  V.St(1,1);
  writeln('a=',V.a,' b=',V.b);
  V.Square;
  readln;
end.
